package com.zdmoney.laocaibao.controller;

//import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.Constants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@Controller
@RequestMapping("/login")
public class LoginController {

    @RequestMapping
    @ResponseBody
    public String login(HttpServletRequest request, String captcha) throws IOException {
        String captchaExpected = (String) request.getSession().getAttribute(Constants.KAPTCHA_SESSION_KEY);
        if (captcha.equalsIgnoreCase(captchaExpected)) {    //验证码不区分大小写
            return "success";
        }
        return "false";
    }
}